import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDictServer extends TcpEchoServer{
    private Map<String,String> dict = new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);

        dict.put("hello","你好"); 
        dict.put("world","世界");
        dict.put("cat","小猫");
        dict.put("dog","小狗"); 
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"没有找到该单词");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer dictServer = new TcpDictServer(9090);
        dictServer.start();
    }
}
